<?php /*a:2:{s:65:"D:\laragon\www\Coupon\application\manage\view\coupon_release.html";i:1601273082;s:55:"D:\laragon\www\Coupon\application\manage\view\base.html";i:1596192950;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
	<meta name="renderer" content="webkit">
<title>后台管理系统</title>
<link rel="stylesheet" href="/static/public/awesome/css/font-awesome.min.css" />

<link rel="stylesheet" href="/static/public/layui/css/layui.css" />

<link rel="stylesheet" href="/static/public/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/static/manage/css/style.css" />

	<link rel="stylesheet" href="/static/public/dist/zoomify.min.css">
	
<script src="/static/public/kindeditor/kindeditor-all.js"></script>
<script src="/static/public/kindeditor/lang/zh_CN.js"></script>
<script src="/static/public/ueditor/ueditor.config.js?t=<?php echo time();?>"></script>
<script src="/static/public/ueditor/ueditor.all.min.js"></script>
<script src="/static/public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<?php if($is_auth): ?>

<script language="javascript" type="text/javascript" src="/static/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="<?php echo url('index/welcome'); ?>"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>商城</span>
            <span class="icon-angle-right"></span>
            <span>优惠券管理</span>
            <span class="icon-angle-right"></span>
            <span>优惠券列表</span>
            <span class="icon-angle-right"></span>
            <span>发布优惠券</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form">
                    <table class="m-table">
                        <tr>
                            <td><label for="">发布人员<em>*</em></label></td>
                            <td>
                                <div class="lay-select m-select-def">
                                    <select name="type" lay-filter="category_id"  lay-verify="required">
                                        <option value="">请选择人员</option>
                                        <option value="1">员工</option>
                                        <option value="2">用户</option>
                                    </select>
                                </div>
                            </td>
                        </tr>
                        <tr id="yh">
                            <td><label for="">选择用户<em>*</em></label></td>
                            <td>
                                <div class="privilege-item lay-checked clearfix" style="margin-bottom: 0px;padding:0;border-bottom:none">
                                    <dl class="clearfix" style="border-bottom:none" id="xuanzhongs">
                                        <dt><h3 class="lay-checkbox"><input type="checkbox" class="select_item_all" lay-skin="primary" title="全选" lay-filter="h3_privilege" /></h3></dt>
                                        <?php if(is_array($member) || $member instanceof \think\Collection || $member instanceof \think\Paginator): if( count($member)==0 ) : echo "" ;else: foreach($member as $key=>$vo): ?>
                                        <dd class="lay-checkbox"><input class="yh" type="checkbox" name="member_id[]" id="member_id" lay-skin="primary" title="<?php echo htmlentities($vo['nickname']); ?>" value="<?php echo htmlentities($vo['id']); ?>"/></dd>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </dl>
                                </div>
                            </td>
                        </tr>
                        <tr id="yg">
                            <td><label for="">选择员工<em>*</em></label></td>
                            <td>
                                <div class="privilege-item lay-checked clearfix" style="margin-bottom: 0px;padding:0;border-bottom:none">
                                    <dl class="clearfix" style="border-bottom:none" id="ygxuanzhongs">
                                        <dt><h3 class="lay-checkbox"><input type="checkbox" class="select_item_all" lay-skin="primary" title="全选" lay-filter="h3_privilege" /></h3></dt>
                                        <?php if(is_array($member_qy) || $member_qy instanceof \think\Collection || $member_qy instanceof \think\Paginator): if( count($member_qy)==0 ) : echo "" ;else: foreach($member_qy as $key=>$vo): ?>
                                        <dd class="lay-checkbox"><input class="yg" type="checkbox" name="member_qy_id[]" id="member_qy_id" lay-skin="primary" title="<?php echo htmlentities($vo['name']); ?>" value="<?php echo htmlentities($vo['id']); ?>"/></dd>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </dl>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%"><label for="offset_price">发布数量<em>*</em></label></td>
                            <td><input  lay-verify="required" type="text" class="u-ipt u-ipt-small" name="number" id="number" placeholder="请输入优惠券发布数量" value="" /></td>
                        </tr>
                    </table>
                    <div class="m-form-btn">
                        <input type="hidden" name="id" id="id" value="<?php echo htmlentities($id); ?>">
                        <button class="u-btn" class="layui-btn" lay-submit lay-filter="formDemo">发布</button>
<!--                        <button id="j_btn" type="button" class="u-btn">发布</button>-->
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php endif; ?>
<input type="hidden" name="action_uri" value="<?php echo url('action'); ?>" />

<input type="hidden" name="redirect_uri" value="<?php echo url('index'); ?>" />

<input type="hidden" name="region_uri" value="/manage/regions/regions" />
<script src="/static/public/js/jquery-1.10.2.js"></script>
<script src="/static/public/js/maniac.ui.js"></script>
<script src="/static/public/layui/layui.js" charset="utf-8"></script>
<script src="/static/public/js/aes.js"></script>
<script src="/static/public/js/mode-ecb-min.js"></script>
<script src="/static/public/js/utils.js"></script>
<script src="/static/public/js/dialog.js"></script>
<script src="/static/manage/js/form.js"></script>
<script src="/static/manage/js/js.js"></script>
<script src="/static/public/js/app.js"></script>
<script src="/static/public/js/encrypt.js"></script>
<script src="/static/public/dist/zoomify.min.js"></script>
<script type="text/javascript">
    $('.fdzoom').zoomify();
</script>

<script>
var aesKey = '<?php echo htmlentities($encrypt_key); ?>';
    $(function(){
        layui.use('layer', function(){
            var user_exists = parseInt('<?php echo !empty($user_exists) ? 1  :  0; ?>');
            var user_forbidden = parseInt('<?php echo !empty($user_forbidden) ? 1  :  0; ?>');
            var quit_force = parseInt('<?php echo !empty($quit_force) ? 1  :  0; ?>');
            var is_auth    = parseInt('<?php echo !empty($is_auth) ? 1  :  0; ?>');
            
            if (user_exists) {
                dialog.error('您所登录的用户已被删除', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (user_forbidden) {
                dialog.error('您的账户已被禁用', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }

            if (quit_force) {
                dialog.error('同一账户同一时间只能一人在线', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (!is_auth) {
                dialog.error('您没有权限执行此操作', function(){
                    window.location.href = history.go(-1);
                    return false;
                });
            }
        });
    })
</script>

<script src="/static/public/js/jquery-ui.min.js"></script>
<script>
    $(function () {
        var keyValue;
        keyValue = $("select[name='type'] option:selected").val();
        console.log(keyValue);
        if (keyValue == 0) {
            $("#yh").hide();
            $("#yg").hide();
        }
        if (keyValue == 1) {
            $("#yg").show();
            $("#yh").hide();
        }
        if (keyValue == 2) {
            $("#yg").hide();
            $("#yh").show();
        }
    })
    layui.use('form', function () {
        var form = layui.form;
        form.on('select', function (data) {
            if (data.value == 0) {
                $("#yh").hide();
                $("#yg").hide();
            }
            if (data.value  == 1) {
                $("#yg").show();
                $("#yh").hide();
            }
            if (data.value  == 2) {
                $("#yg").hide();
                $("#yh").show();
            }
            form.render();
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            var member_id = [];
            //员工
            if (data.field.type == 1){
                $(".yg:checked").each(function () {
                    member_id.push($(this).val());
                });
                if (member_id.length ===0){
                    layer.msg("请选择员工");
                    return false;
                }
            }
            //用户
            if (data.field.type == 2){
                $(".yh:checked").each(function () {
                    member_id.push($(this).val());
                });
                if (member_id.length ===0){
                    layer.msg("请选择用户");
                    return false;
                }
            }

            $.post('/manage/coupon/release_coupon',{
                id : data.field.id,
                type : data.field.type,
                number : data.field.number,
                member_id :member_id,
            },function (res){
                // if (res.status){
                //
                // }
                layer.msg(res.message);
            })
            return false;
        });
    });
</script>

</body>
</html>